import {AlignItemsMap, ClassTypeMap, JustifyContentMap} from "@/common/map";

export default defineComponent({
    props: {
        // 文本
        text: {
            type: [String, Number],
            default: ""
        },
        // 显示方式
        display: {
            type: String as PropType<"block" | "inline-block" | "flex" | "inline-flex" | "grid">,
            default: "grid"
        },
        // 前缀图标
        prefixIcon: {
            type: String,
            default: ""
        },
        // 前缀图标颜色
        prefixIconColor: {
            type: String as PropType<ColorType>,
            default: ""
        },
        // 前缀图标大小
        prefixIconSize: {
            type: [String, Number],
            default: ""
        },
        // 前缀文本
        prefixText: {
            type: String,
            default: ""
        },
        // 前缀文本大小
        prefixTextFontSize: {
            type: [String, Number],
            default: ""
        },
        // 前缀文本颜色
        prefixTextColor: {
            type: String as PropType<ColorType>,
            default: ""
        },
        // 前缀文本字重
        prefixTextFontWeight: {
            type: [String, Number],
            default: "inherit",
            validator: (value: string | number): boolean =>
            {
                if (isString(value))
                {
                    return ["bold", "bolder", "lighter", "normal", "inherit", "initial", "revert", "revert-layer", "unset"].includes(value);
                }

                return true;
            }
        },
        // 前缀文本间距
        prefixTextGap: {
            type: [String, Number],
            default: ""
        },
        // 后缀图标
        suffixIcon: {
            type: String,
            default: ""
        },
        // 后缀图标颜色
        suffixIconColor: {
            type: String as PropType<ColorType>,
            default: ""
        },
        // 后缀图标大小
        suffixIconSize: {
            type: [String, Number],
            default: ""
        },
        // 后缀文本
        suffixText: {
            type: String,
            default: ""
        },
        // 后缀文本大小
        suffixTextFontSize: {
            type: [String, Number],
            default: ""
        },
        // 后缀文本颜色
        suffixTextColor: {
            type: String as PropType<ColorType>,
            default: ""
        },
        // 后缀文本字重
        suffixTextFontWeight: {
            type: [String, Number],
            default: "inherit",
            validator: (value: string | number): boolean =>
            {
                if (isString(value))
                {
                    return ["bold", "bolder", "lighter", "normal", "inherit", "initial", "revert", "revert-layer", "unset"].includes(value);
                }

                return true;
            }
        },
        // 后缀文本间距
        suffixTextGap: {
            type: [String, Number],
            default: ""
        },
        // 文本和前缀以及后缀的Y轴交叉对齐方式
        fixAlignItems: {
            type: String as PropType<AlignItemsType>,
            default: "baseline",
            validator: (value: string): boolean =>
            {
                return AlignItemsMap.includes(value);
            }
        },
        // 图标与文本之间的间距（单位：px）
        gap: {
            type: [String, Number],
            default: 4
        },
        // 字体大小
        fontSize: {
            type: [String, Number],
            default: 16
        },
        // 字体
        fontFamily: {
            type: String as PropType<FontFamilyType>,
            default: "normal",
            validator: (value: string): boolean =>
            {
                return ["normal", "din-light", "din-regular", "din-bold", "pu-hui-105-heavy", "pu-hui-115-black", "pu-hui-35-thin", "pu-hui-45-light", "pu-hui-55-regular", "pu-hui-55-regular-85-bold", "pu-hui-65-medium", "pu-hui-75-semi-bold", "pu-hui-95-extra-bold", "xing-qiu-hei"].includes(value);
            }
        },
        // 字体颜色
        color: {
            type: String,
            default: ""
        },
        // 预制样式
        type: {
            type: String as PropType<ClassType>,
            default: "info",
            validator: (value: string): boolean =>
            {
                return ClassTypeMap.includes(value);
            }
        },
        // 字重
        fontWeight: {
            type: [String, Number],
            default: "normal"
        },
        // Y轴交叉对齐方式
        alignItems: {
            type: String as PropType<AlignItemsType>,
            default: "center",
            validator: (value: string): boolean =>
            {
                return AlignItemsMap.includes(value);
            }
        },
        // X轴交叉对齐方式
        justifyContent: {
            type: String as PropType<JustifyContentType>,
            default: "flex-start",
            validator: (value: string): boolean =>
            {
                return JustifyContentMap.includes(value);
            }
        },
        // 行高（单位：px）
        lineHeight: {
            type: [String, Number],
            default: ""
        },
        // 修饰器
        decoration: {
            type: String as PropType<"none" | "underline" | "line-through">,
            default: "none"
        },
        // padding值（单位：px）[上,右,下,左]顺序
        padding: {
            type: Array as PropType<string[] | number[]>,
            default: (): string[] | number[] =>
            {
                return [0, 0, 0, 0];
            }
        },
        // 文本类型
        textType: {
            type: String as PropType<"text" | "mobile" | "money" | "name">,
            default: "text"
        },
        // 文本是否脱敏格式化（仅textType取值mobile、money、name时有效）
        format: {
            type: Boolean,
            default: false
        },
        // 等宽字体
        tabular: {
            type: Boolean,
            default: false
        },
        // 文本溢出限制（不限制表示文字无限制换行）
        limit: {
            type: Boolean,
            default: false
        },
        // 溢出后折行数量
        clamp: {
            type: Number,
            default: 1
        },
        // 处理元素空白
        whiteSpace: {
            type: String as PropType<"normal" | "nowrap" | "pre" | "pre-line" | "pre-wrap" | "break-spaces">,
            default: "normal"
        },
        // 单词换行
        wordBreak: {
            type: String as PropType<"normal" | "break-all" | "keep-all" | "break-word">,
            default: "normal"
        },
        // 是否阻止事件传播
        stop: {
            type: Boolean,
            default: false
        },
        // 是否阻止事件默认行为
        prevent: {
            type: Boolean,
            default: false
        }
    }
});